import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/mq/topic',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/mq/topic',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/mq/topic',
    method: 'put',
    data
  })
}

export function get(id) {
  return request({
    url: 'api/mq/topic/' + id,
    method: 'get'
  })
}

export function producer(clusterId, topicName, key, value) {
  return request({
    url: 'api/mq/topic/producer',
    method: 'post',
    params: {
      clusterId: clusterId,
      topicName: topicName,
      key: key,
      value: value
    }
  })
}

export function consumer(data) {
  return request({
    url: 'api/mq/topic/consumer',
    method: 'post',
    data
  })
}

export function getByClusterId(clusterId) {
  return request({
    url: 'api/mq/topic/cluster/' + clusterId,
    method: 'get'
  })
}

export default { add, edit, del }
